﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;

namespace Property.Windows
{
    /// <summary>
    /// Contains words that can come immediately after the opening
    /// of a property description. 
    /// </summary>
    public static class ReloadableExtensionsReactiveWindows
    {
        /// <summary>
        /// <para>... asynchronously ...</para>
        /// <para>New values will be loaded on a new thread and applied on Dispatcher thread.</para>
        /// </summary>
        /// <param name="testMode">Tell me if I have to ignore this word.</param>
        public static ISequenceConveyor<T> Async<T>(this Reloadable<T> source, bool testMode = false)
        {
            return source.Reactive().Async(testMode);
        }

        /// <summary>
        /// <para>... synchronously if the call passes through the throttle (when) ...</para>
        /// <para>( ! ) Don't forget to dispose of what you create with this word.</para>
        /// </summary>
        /// <param name="dueTime">Tell me how long I should wait for another call
        /// before letting this one pass.</param>
        /// <param name="testMode">Tell me if I have to ignore this word.</param>
        public static IReloaderPrototype<T> Throttle<T>(this Reloadable<T> source, TimeSpan dueTime, bool testMode = false)
        {
            return source.Each().Throttle(dueTime, testMode);
        }
    }
}
